home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1833
/
1833.xpi
/
chrome
/
yoono.jar
/
content
/
yoono
/
aboutyoono.xul
< prev
next >
Wrap
Extensible Markup Language
|
2009-12-16
|
9KB
|
240 lines
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload = "init();"
>
<script>
<![CDATA[
const CI = Components.interfaces;
const CL = Components.classes;
const PREFS = CL["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefService).getBranch("");
Components.utils.import("resource://yoono/yoonoService.js");
Components.utils.import("resource://yoono/yoonoDialogs.js");
Components.utils.import("resource://yoono/yoonoPrefs.js");
Components.utils.import("resource://yoono/yoonoLog.js");
Components.utils.import("resource://yoono/yoonoKeyValueDB.js");
var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
var logPath;
var dataToImport = [];
function init() {
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get('ProfDS', Components.interfaces.nsIFile);
var log = file.clone();
log.append('yoono');
log.append('yoono.log');
logPath = log.path;
var FFPath = file.path;
var labelProf = document.getElementById('profile');
var textNode = document.createTextNode(FFPath);
labelProf.appendChild(textNode);
labelProf.setAttribute('style', '-moz-user-select:text;-moz-user-focus:normal');
if(YOONO_LOG.isDebugEnabled()) {
var debuglevelonly = document.getElementById('debuglevelonly');
if(debuglevelonly) debuglevelonly.removeAttribute('hidden');
}
}
function logout() {
YOONO_DIALOGS.traverseBrowsers(YOONO_CMPT.closeSidebar);
YOONO_PREFS.set('userid', '', YOONO_PREFS.PREF_STRING);
}
function razSidebarComposition() {
YOONO_DIALOGS.traverseBrowsers(YOONO_CMPT.closeSidebar);
YOONO_KEYVALUEDB.deleteKeyValue('sidebarYoodgetList');
YOONO_DIALOGS.traverseBrowsers(YOONO_CMPT.openSidebar);
}
function razYoonoButton() {
YOONO_DIALOGS.traverseBrowsers(installYoonoButton);
}
function installYoonoButton(win) {
doc = win.document;
win.yoonoGlob.installYoonoButton();
}
function sendStats () {
YOONO_CMPT.checkStats('manual');
}
function openKVDB () {
document.location = 'chrome://yoono/content/admin.xul';
}
function currentLogFile() {
document.location = 'file:///' + logPath;
}
function exportGroups() {
var reqTag = "SELECT id, is_alert, json_data, display_name from tag";
var reqTagInsert = "INSERT INTO tag (id, is_alert, json_data, display_name) VALUES (?, ?, ?, ?)";
YOONO_CMPT._globalService.storageManager.executeAsyncSql(reqTag, null, function(aResult) {
var data = aResult.getData();
var tagList = data[0];
var reqTagUser = "SELECT external_id, provider_id, tag_id from users_tags";
var reqTagUserInsert = "INSERT INTO users_tags (external_id, provider_id, tag_id) VALUES (?, ?, ?)"
YOONO_CMPT._globalService.storageManager.executeAsyncSql(reqTagUser, null, function(aResult) {
var data = aResult.getData();
var tagUsersList = data[0];
var export = [{'reqSelect': reqTag, 'data':tagList, 'reqInsert':reqTagInsert, 'reqDelete': "DELETE FROM tag"},
{'reqSelect' : reqTagUser, 'data' : tagUsersList, 'reqInsert':reqTagUserInsert, 'reqDelete': "DELETE FROM users_tags"}
];
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get('ProfDS', Components.interfaces.nsIFile);
file.append('yoono');
file.append('groups.exp');
if(file.exists()) {
var remove = confirm("The export file 'groups.exp' exists. Overwrite ?");
if(!remove) return;
file.remove(true);
}
var fileOutputStream = CL['@mozilla.org/network/file-output-stream;1'].createInstance(CI.nsIFileOutputStream);
fileOutputStream.init(file, 0x02 | 0x08 | 0x10, 0600, 0);
var converter = CL['@mozilla.org/intl/converter-output-stream;1'].createInstance(CI.nsIConverterOutputStream);
converter.init(fileOutputStream, 'UTF-8', 1024, '-');
converter.writeString(nativeJSON.encode(export));
converter.flush();
fileOutputStream.close();
});
});
}
function importGroups() {
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get('ProfDS', Components.interfaces.nsIFile);
file.append('yoono');
file.append('groups.exp');
if(!file.exists()) {
alert("The export file 'groups.exp' does not exist.");
return;
}
var istream = CL["@mozilla.org/network/file-input-stream;1"].createInstance(CI.nsIFileInputStream);
istream.init(file, 0x01, 0444, 0);
var converter = CL["@mozilla.org/intl/converter-input-stream;1"].createInstance(CI.nsIConverterInputStream);
converter.init(istream, 'UTF-8', 1024, '-');
var line = {};
var buf="";
while(converter.readString(4096, line)) {
buf+=line.value;
}
istream.close();
dataToImport = nativeJSON.decode(buf);
doImportData();
}
function doImportData() {
var theData = dataToImport.shift();
if(!theData || !theData.data) {
alert("Import done.");
return;
}
YOONO_CMPT._globalService.storageManager.executeAsyncSql(theData.reqDelete, null, function(aResult) {
YOONO_CMPT._globalService.storageManager.executeAsyncSql(theData.reqInsert, theData.data, function(aResult) {
doImportData();
});
});
}
function checkDB() {
YOONO_CMPT._globalService.storageManager.schemaRevisionChecker( function (aResult) {
if(aResult.fileRev == aResult.DBRev) {
alert("DB schema ok");
} else {
alert(aResult.message);
}
});
}
function compactDB() {
YOONO_CMPT._globalService.storageManager.compactStorage( function (aResult) {
alert("Done");
});
}
function showAddOns() {
var themes = "\n\nInstalled themes :\n";
var aDebugInfo = 'general.useragent.extra.firefox : '+PREFS.getCharPref('general.useragent.extra.firefox')+'\n';
aDebugInfo += 'general.useragent.locale : '+PREFS.getCharPref('general.useragent.locale')+'\n\n';
aDebugInfo += 'Installed extensions :\n';
var aExtManager = CL["@mozilla.org/extensions/manager;1"].getService(CI.nsIExtensionManager);
var aItemList = aExtManager.getItemList(CI.nsIUpdateItem.TYPE_ANY, { });
for(var i in aItemList) {
if(4 != aItemList[i].type) {
aDebugInfo += aItemList[i].name+', version='+aItemList[i].version+', update-url='+aItemList[i].updateRDF+'\n';
} else {
themes += aItemList[i].name+', version='+aItemList[i].version+', update-url='+aItemList[i].updateRDF+'\n';
}
}
alert(aDebugInfo + themes);
}
]]>
</script>
<spacer height="20px"/>
<hbox>
<label value="Profile directory : "/>
<label id="profile" />
</hbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Check DB creation vs current schema" oncommand="checkDB()"/>
</hbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Compact DB to reclaim available disk space" oncommand="compactDB()"/>
</hbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Support Information" oncommand="showAddOns()"/>
</hbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Reset Sidebar to default widgets" oncommand="razSidebarComposition()"/>
</hbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Reset Yoono button to default position" oncommand="razYoonoButton()"/>
</hbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Current Log File" oncommand="currentLogFile()"/>
</hbox>
<vbox id="debuglevelonly" hidden="true">
<spacer height="20px"/>
<hbox align="center" id="statbox">
<button label="Send Stats" oncommand="sendStats()"/>
</hbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Open KeyValue Storage (carefull!)" oncommand="openKVDB()"/>
</hbox>
</vbox>
<spacer height="20px"/>
<hbox align="center">
<button label="Export Groups" oncommand="exportGroups()"/>
<button label="Import Groups" oncommand="importGroups()"/>
</hbox>
<!--<spacer height="20px"/>
<hbox id="logout" align="center">
<button label="Logout" oncommand="logout()"/>
</hbox>
-->
</window>